package Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Info.AdminInfo;
import Manage.AdminManage;

public class UpdateAdminS extends HttpServlet{
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		
		int id=Integer.parseInt(request.getParameter("id"));
		String name=request.getParameter("name");
		String password=request.getParameter("password");
		
		AdminManage adminm=new AdminManage();
		AdminInfo admin=new AdminInfo(id,name,password);
		
		AdminInfo a = adminm.Login(name);
		if(!a.getPassword().equals(password)) {
			adminm.Update(admin);
			request.getRequestDispatcher("UpdatePasswordRTishi.jsp").forward(request, response);
		} else {
			HttpSession ssion=request.getSession();
			ssion.setAttribute("name", name);
			request.getRequestDispatcher("UpdatePasswordWTishi.jsp").forward(request, response);
			
		}
	}
}
